package com.chixing.ih.module.programmer.mapper.provider;

import org.apache.ibatis.jdbc.SQL;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘岩
 * Date: 2020-09-30
 * Time: 13:25
 *
 * @version 1.0
 */
public class AttentionMapperProvider {

    public String insertOne() {
        return new SQL() {{
            INSERT_INTO("tbl_attention");
            VALUES("follower_id", "#{followerId}");
            VALUES("followed_id", "#{followedId}");
            VALUES("followed_time", "#{followedTime}");
        }}.toString();
    }

    public String deleteOne() {
        return new SQL() {{
            UPDATE("tbl_attention");
            SET("follow_status=1");
            WHERE("follower_id=#{followerId} AND followed_id=#{followedId}");
        }}.toString();
    }

    public String getStatus() {
        return new SQL() {{
            SELECT("follow_status");
            FROM("tbl_attention");
            WHERE("follower_id=#{followerId} AND followed_id=#{followedId} AND follow_status=0");
        }}.toString();
    }

    /**
     * 关注的人
     *
     * @return
     */
    public String listFollower() {
        return new SQL() {{
            SELECT("*");
            FROM("tbl_attention");
            WHERE("follow_status=0 AND follower_id=#{followerId}");
        }}.toString();
    }

    public String followerNum() {
        return new SQL() {{
            SELECT("count(1)");
            FROM("tbl_attention");
            WHERE("follow_status=0 AND follower_id=#{followerId}");
        }}.toString();
    }

    public String fanNum() {
        return new SQL() {{
            SELECT("count(1)");
            FROM("tbl_attention");
            WHERE("follow_status=0 AND followed_id=#{followedId}");
        }}.toString();
    }

    /**
     * 粉丝
     *
     * @return
     */
    public String listFan() {
        return new SQL() {{
            SELECT("*");
            FROM("tbl_attention");
            WHERE("follow_status=0 AND followed_id=#{followedId}");
        }}.toString();
    }

}
